﻿using infoMECHANICA.NHibernateORM.TestMappings;
using NHibernate.Criterion;

namespace infoMECHANICA.NHibernateORM.ExampleProgram
{
    /// <summary>
    /// See http://www.codeplex.com/nhcb/Wiki/View.aspx?title=RESTRICTIONS_AND_MERGING&referringTitle=Home for details
    /// </summary>
    public class Example6 : IExample   
    {
        #region IExample Members

        public string Title
        {
            get { return "Exmaple 6 - Merging query results with restrictions"; }
        }

        public DetachedCriteria ComposeCriteria()
        {
            EmployeeRec employeeRec = new EmployeeRec();
            employeeRec.Salary.SetGt(8000);

            EmployeeRec employeeRestrictionsRec = new EmployeeRec();
            employeeRestrictionsRec.Job.Name.SetNotEq("MANAGER");

            DetachedCriteria criteria = (employeeRec & employeeRestrictionsRec).BuildCriteria();

            return criteria;
        }

        #endregion
    }
}
